/** @format */
// https://juejin.cn/post/7281825352530296843?searchId=20240412161355C16C191FAC631802BFCF#heading-4
import type {DirectiveBinding} from 'vue';
import {createApp} from 'vue';
import Loading from './Loading.vue';

export default {
    mounted: (el: any, binding: DirectiveBinding) => {
        const {value, arg} = binding;
        const loadingApp = createApp(Loading);
        console.log(loadingApp);
        const loadingIns = loadingApp.mount(document.createElement('div'));
        console.log('ins:', loadingIns);

        if (value) {
            // 不能从顶层去设置props吗？
            arg && (loadingIns as any).setTitle(arg);
            // 实例的dom元素
            // console.log('el', loadingIns.$el);

            el.appendChild(loadingIns.$el);
        }
    },
};
